home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / FrexxEd / fpl / FillText.FPL < prev    next >
Encoding:
Text File  |  1996-09-27  |  2.0 KB  |  82 lines

  1. // $Id: FillText.FPL 1.2 1995/10/03 15:32:48 jskov Exp $
  2. // $VER: FillText.FPL 1.1 (04.10.95) © Jesper Skov
  3.  
  4. export string ft_indention="";
  5.  
  6. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» fillText ««
  7. export void fillText()
  8. {
  9.   int i=0;
  10.  
  11.   if (ReadInfo("line_length")==1){
  12.     ReturnStatus("Place cursor in a paragraph!");
  13.     return;
  14.   }
  15.  
  16.   Visible(0);
  17.  
  18.   // Find topmost line
  19.   while((ReadInfo("line_length")>1) && ReadInfo("line")>1)
  20.     CursorUp();
  21.   if(ReadInfo("line")!=1)
  22.     CursorDown();
  23.  
  24.   CursorDown();Home();
  25.  
  26.   // Put all lines in paragraph on same line
  27.   while(ReadInfo("line_length")>1){
  28.     Backspace();Clean("Output(\" \");");
  29.     CursorDown();Home();
  30.   }
  31.   CursorUp();
  32.  
  33.   // Copy&delete leading spaces
  34.   while(Isspace(GetChar(i)))
  35.     i++;
  36.   ft_indention = substr(GetLine(),0,i);
  37.   Delete(i);
  38.  
  39.   BlockMark(0);
  40.   BlockMarkLine(-1);
  41.  
  42.   Replace(1,"\t"," ","=bf+");                // replace tabs with space
  43.   Home();
  44.   Replace(1,"  +"," ","=bfw+");                // replace multiple spaces with space
  45.   Home();
  46.   if(ReadInfo("fill_text_US")){                // if wanted, set US double space
  47.     Replace(1,". ",".  ","=bf+");
  48.     Home();
  49.   }
  50.  
  51.   BlockMark(0);
  52.  
  53.   Clean("Output(ft_indention);");
  54.  
  55.   // Now split line up in valid sized single lines
  56.   while(GetCursor(ReadInfo("line_length"))>ReadInfo("wall_right")){
  57.     // If a word is crossing the wall_right, go left of it.
  58.     GotoLine(ReadInfo("line"),GetByte(ReadInfo("wall_right")));
  59.     while(!Isspace(GetChar(ReadInfo("byte_position")-1))){
  60.       CursorLeftWord();
  61.       if (ReadInfo("column")==1){            // very long word!
  62.         CursorRightWord();                    // simply go back!
  63.         break;
  64.       }
  65.     }
  66.     Backspace();
  67.     if (Isspace(GetChar(ReadInfo("byte_position")-1)))
  68.       Backspace();                            // clear extra for US .
  69.     Clean("Output(\"\n\"+ft_indention);");
  70.   }     
  71.  
  72.   // Delete last space there may be after a .
  73.   GotoLine(ReadInfo("line"),-1);
  74.   if(Isspace(GetChar(ReadInfo("byte_position")-1)))
  75.     Backspace();
  76.  
  77.   Visible(1);RedrawScreen();
  78. }
  79.  
  80. //»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Info vars ««
  81. ConstructInfo("fill_text_US","","","WBG(display)","",0,1,0);
  82.